package com.atguigu.mvc.controller;

import com.atguigu.mvc.entity.Employee;
import com.atguigu.mvc.entity.School;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author : zzf
 * @date : 2021/1/6
 */

@Controller
@RequestMapping("/param/to")
public class MvcTest {
    @RequestMapping("one/value")
    public String testOne(HttpServletRequest request, HttpSession session,
                          @RequestParam String userName,
                          String password
    ){
        System.out.println("request = " + request);
        System.out.println("session = " + session);
        System.out.println("userName = " + userName);
        System.out.println("password = " + password);
        return "target";
    }

    @RequestMapping("/multi/value")
    public String testTwo(@RequestParam List<String> team){
        System.out.println("team = " + team);
        return "target";
    }

    @RequestMapping("/entity")
    public String testThree(Employee employee, Model model){
        System.out.println("employee = " + employee);
        model.addAttribute("appleAttrName", "appleAttrValue");
        return "forward:/WEB-INF/pages/target.jsp";
    }
}
